package com.feilo.action;

import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.ServletActionContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.feilo.biz.AdminBiz;
import com.feilo.biz.impl.AdminBizImpl;
import com.feilo.entity.Admin;
import com.feilo.util.ProReader;
import com.opensymphony.xwork2.ActionContext;
import com.zoo.pojo.Page;

@Controller
@Scope("prototype")
public class adminAction {
	private String msg;
	@Resource
	AdminBiz us=new AdminBizImpl();
	Admin admin;
	String ip=ServletActionContext.getRequest().getRemoteAddr();
	String addName=(String) ActionContext.getContext().getSession().get("admin");
    private int pageNo = 1; 
    private Page pageInfo;
	private String url ;
	private String skipUrl;
	private String text;
	List<Admin> admins;
	int starts,ends,record,page;
	public String adminList(){
		List<Admin> list =us.getAdmins();
		int pageSize = Integer.parseInt(ProReader.getInstance().getProperty("pageSize"));
		int showCount = Integer.parseInt(ProReader.getInstance().getProperty("showCount"));
        pageInfo = new Page(pageNo, pageSize, admins.size(),showCount);   
        list = admins.subList(pageInfo.getRecordStart() - 1, pageInfo.getRecordEnd());  
        url="admin_adminList.do";   
		return "adminList";
	}
	
	/**
	 * �����û��б�
	 */
	public String search(){
		List<Admin> list = us.getAdminsBySerch(admin.getAd_username()); 
		int pageSize = Integer.parseInt(ProReader.getInstance().getProperty("pageSize"));
		int showCount = Integer.parseInt(ProReader.getInstance().getProperty("showCount"));
        Page pageInfo = new Page(pageNo, pageSize, admins.size(),showCount);   
        list = admins.subList(pageInfo.getRecordStart() - 1, pageInfo.getRecordEnd()); 
        url="admin_search.do";   
		return "adminList";
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public int getPageNo() {
		return pageNo;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}

	public Page getPageInfo() {
		return pageInfo;
	}

	public void setPageInfo(Page pageInfo) {
		this.pageInfo = pageInfo;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getSkipUrl() {
		return skipUrl;
	}

	public void setSkipUrl(String skipUrl) {
		this.skipUrl = skipUrl;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public Admin getAdmin() {
		return admin;
	}

	public void setAdmin(Admin admin) {
		this.admin = admin;
	}

	public List<Admin> getAdmins() {
		return admins;
	}

	public void setAdmins(List<Admin> admins) {
		this.admins = admins;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public int getStarts() {
		return starts;
	}

	public void setStarts(int starts) {
		this.starts = starts;
	}

	public int getEnds() {
		return ends;
	}

	public void setEnds(int ends) {
		this.ends = ends;
	}

	public int getRecord() {
		return record;
	}

	public void setRecord(int record) {
		this.record = record;
	}
}
